import React from 'react'

/**
 * 复选框
 *
 * @author leonzhangxf 20190117
 */
class SearchAreaCheckbox extends React.Component {
  constructor(props) {
    super(props);

    this.handleShowOnlyStockChange = this.handleShowOnlyStockChange.bind(this);
  }

  handleShowOnlyStockChange(event) {
    if (this.props.onStockCheckboxChange) {
      this.props.onStockCheckboxChange(event.target.checked);
    }
  }

  render() {
    let value = this.props.showOnlyStock;
    return (
      <div>
      <input className="SearchArea-Checkbox"
             type="checkbox" name="showOnlyStock" checked={value}
             onChange={this.handleShowOnlyStockChange}/> Only show products in stock
      </div>
    );
  }
}

export default SearchAreaCheckbox;